
import { getToken, setToken, removeToken } from '@/utils/auth'
import { resetRouter } from '@/router'
import  {_API} from '@/api/bai'

const types = {
  
}
const state = {
        patientInfo:{},  //病人信息
        tableData1:[],  //门诊数据
        memberInfo:{},  //用户得id

        huixian_detail:{},
        mz_log_list:{}, //门诊日志列表
        mz_statistics_list:{},

        YZ_chufang_status:'',

        service_print_list:[],  //打印组合列表暂时
      
}

const mutations = {
  set_YZ_chufang_status(state,param){
    state.YZ_chufang_status=param;
 },
  set_memberInfo(state,param){
    state.memberInfo=param;
 },
  set_tableData1(state,param){
    state.tableData1=param;
 },
 set_patientInfo(state,param){
    state.patientInfo=param;
 },
 set_huixian_detail(state,param){
  state.huixian_detail=param;
  },
  set_mz_log_list(state,param){
      state.mz_log_list=param;
  },
  set_mz_statistics_list(state,param){
    state.mz_statistics_list=param;
},

set_service_print_list(state,param){
  state.service_print_list=param;
}, 
  
}

const actions = {
  
  getPrintRecipeItem({ commit }, d){
    return new Promise((resolve, reject) => {
      _API.getPrintRecipeItem(d).then((res)=>{
         
            if (res.code === 200 && res.data) {
              commit('set_service_print_list', res.data)
          
              resolve(res)
           
          } else {
              commit('set_service_print_list', {})
              resolve()
          }
      })
    })
  },
  getClinic_doctorGetMedicalRecordDetail({ commit }, d){
    return new Promise((resolve, reject) => {
      _API.getClinic_doctorGetMedicalRecordDetail(d).then((res)=>{
         
            if (res.code === 200 && res.data) {
              commit('set_huixian_detail', res.data)
          
              resolve(res)
           
          } else {
              commit('set_huixian_detail', {})
              resolve()
          }
      })
    })
  },
  getStatisticClinicOrderList({ commit }, d){
    return new Promise((resolve, reject) => {
      _API.getStatisticClinicOrder(d).then((res)=>{
         
            if (res.code === 200 && res.data) {
            
              commit('set_mz_statistics_list',res.data)
          
              resolve(res)
           
          } else {
              commit('set_mz_statistics_list', {})
              resolve()
          }
      })
    })
  },
  getClinic_doctorWorkLogList({ commit }, d){
    return new Promise((resolve, reject) => {
      _API.getClinic_doctorWorkLog(d).then((res)=>{
         
            if (res.code === 200 && res.data) {
            
              commit('set_mz_log_list',res.data)
          
              resolve(res)
           
          } else {
              commit('set_mz_log_list', {})
              resolve()
          }
      })
    })
  },
  
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

